function trig = bciAnalog2Trig(dat,order)

threshold = 3.5; % threshold for high bit ;

%get trigger information
dat=dat>(threshold);

% convert binary information; order defines bit value from low to high
trig = power(2,0:size(dat,1)-1)*dat(order,:);